#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import datetime
import os
import shutil
import pytz

uc_center = "3.65.55.91"
game = "3.65.55.91"
game_port = 3000
uc_center_port = 1000

# uc_center = "database-1.cf7c2qhlbyej.eu-central-1.rds.amazonaws.com"
# game = "azal-game.cf7c2qhlbyej.eu-central-1.rds.amazonaws.com"
# game_port = 3306
# uc_center_port = 3306

def get_specified_timestamps():
    utc_now = datetime.datetime.now(pytz.UTC)
    beijing_tz = pytz.timezone('Asia/Shanghai')
    beijing_time = utc_now.astimezone(beijing_tz)

    today_05 = beijing_time.replace(hour=5, minute=0, second=0, microsecond=0)
    yesterday = beijing_time - datetime.timedelta(days=1)
    yesterday_05 = yesterday.replace(hour=5, minute=0, second=0, microsecond=0)
    yesterday_05_timestamp = yesterday_05.timestamp()

    if beijing_time.hour >= 5:
        today_05_timestamp = today_05.timestamp()
        return yesterday_05_timestamp, today_05_timestamp
    else:
        day_of_yesterday = beijing_time - datetime.timedelta(days=2)
        day_of_yesterday_05 = day_of_yesterday.replace(hour=5, minute=0, second=0, microsecond=0)
        day_of_yesterday_05_timestamp = day_of_yesterday_05.timestamp()
        return day_of_yesterday_05_timestamp, yesterday_05_timestamp


# 时间戳格式化
def format_timestamp(timestamp):
    dt = datetime.datetime.fromtimestamp(timestamp)
    return dt.strftime("%Y年%m月%d日%H时")


def checkFile(folder_name):
    # 检查文件夹是否存在
    if os.path.exists(folder_name):
        try:
            # 删除已存在的文件夹
            shutil.rmtree(folder_name)
            print(f"已删除文件夹: {folder_name}")
        except Exception as e:
            print(f"删除文件夹时出错: {e}")
    else:
        print(f"文件夹 {folder_name} 不存在。")

    # 创建新的文件夹
    try:
        os.mkdir(folder_name)
        print(f"成功创建文件夹: {folder_name}")
    except Exception as e:
        print(f"创建文件夹时出错: {e}")